import { NestFactory } from "@nestjs/core";
import { NestExpressApplication } from "@nestjs/platform-express";
import { AppModule } from "./app.module";
import { join } from "path";
import { LogLevel } from "@nestjs/common";
import axios from "axios";

async function bootstrap() {
    let { LOG_LEVEL = "error" } = process.env;
    const LogLevels = ["error", "warn", "log", "debug", "verbose"] as LogLevel[];
    if (!LogLevels.includes(LOG_LEVEL as LogLevel)) {
        LOG_LEVEL = "error";
    }
    const app = await NestFactory.create<NestExpressApplication>(AppModule, {
        cors: true,
        logger: LogLevels.slice(0, LogLevels.indexOf(LOG_LEVEL as LogLevel) + 1),
    });
    app.useStaticAssets(join(__dirname, "..", "public"));
    app.setBaseViewsDir(join(__dirname, "..", "views"));
    app.setViewEngine("hbs");
    await app.listen(process.env.PORT || 4016);
}
bootstrap();
